package com.zhangye.test.service;

import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;

import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhangye.test.mapper.WechatOrderInfoMapper;

@Service
public class WeChatAsyncService {

	Logger logger = LoggerFactory.getLogger(WeChatAsyncService.class);
	
	@Autowired
	private WechatOrderInfoMapper wechatOrderInfoMapper;
	
	public Map<String, Object> async(Map<String, Object> wxPayResult) throws ParseException, DocumentException{
		
		Map<String, Object> results = new HashMap<String, Object>();
		
		Map<String, Object> return_code = (Map<String, Object>) wxPayResult.get("return_code");
		Map<String, Object> result_code = null;
		Map<String, Object> trade_state = (Map<String, Object>) wxPayResult.get("trade_state");
		Map<String, Object> total_fee = (Map<String, Object>) wxPayResult.get("total_fee");
		String tradestate = (String) return_code.get("return_code");

		if (return_code.get("return_code") == null
				|| return_code.get("return_code").equals("")) {
			logger.info("微信支付异步返回----->未获取到微信返回结果");
		} else {
			result_code = (Map<String, Object>) wxPayResult.get("result_code");
		}

		return results;
	}
	
}
